package com.nebula.rabbitmq.listen;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: WangZhongLiang
 * @Date: 2019/9/3
 */

@Component
public class MqListen {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "nebula.create.page.queue", durable = "true"),
            exchange = @Exchange(
                    value = "nebula.item.exchange",
                    ignoreDeclarationExceptions = "true",
                    type = ExchangeTypes.TOPIC),
            key = {"item.select", "item.insert"}))
    public void listenCreate(String news) throws Exception {
        if (news == null) {
            return;
        }
        // 获取消息
        System.out.println("接受到的消息是:"+news);
    }
}


